<%@ page contentType="text/html;charset=UTF-8" language="java" isELIgnored="false" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<html>
<head>
    <title>食品分类列表</title>
    <style>
        table {
            width: 100%;
            border-collapse: collapse;
            margin-top: 20px;
        }
        table, th, td {
            border: 1px solid #ddd;
        }
        th, td {
            padding: 12px;
            text-align: left;
        }
        th {
            background-color: #4CAF50;
            color: white;
        }
        tr:nth-child(even) {
            background-color: #f2f2f2;
        }
        a {
            color: #4CAF50;
            text-decoration: none;
            margin-right: 10px;
        }
        a:hover {
            text-decoration: underline;
        }
    </style>
</head>
<body>
<h2>食品分类列表</h2>
<!-- 修改为正确的URL路径 -->
<a href="${pageContext.request.contextPath}/foodscategory/add">添加分类</a>
<table>
    <tr>
        <th>成品分类id</th>
        <th>分类名称</th>
        <th>分类描述</th>
        <th>创建时间</th>
        <th>操作</th>
    </tr>
    <c:forEach items="${categories}" var="category"> <!-- 修改为正确的属性名 -->
        <tr>
            <td>${category.categoryid}</td>
            <td>${category.categoryname}</td>
            <td>${category.description}</td>
            <td>${category.createtime}</td>
            <td>
                <!-- 修改为正确的URL路径 -->
                <a href="${pageContext.request.contextPath}/foodscategory/edit/${category.categoryid}">编辑</a>
                <a href="${pageContext.request.contextPath}/foodscategory/delete/${category.categoryid}"
                   onclick="return confirm('确定删除吗？')">删除</a>
            </td>
        </tr>
    </c:forEach>
</table>
</body>
</html>